package com.liudadan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ResponseBody
@RequestMapping("json")
@Controller
public class JsonController {

    @GetMapping("getUser")
    public User getUser(){
        User user = new User();
        user.setName("liudadan");
        user.setAge(18);
        return user;
    }

    @GetMapping("getUser2")
    public List<User> getUser2(){
        User user = new User();
        user.setName("liudadan");
        user.setAge(18);
        List<User> list = new ArrayList<User>();
        list.add(user);
        return list;
    }
}
